<?php
declare (strict_types = 1);
namespace app\admin\model;

use app\admin\model\Common;

class News extends Common
{
	/**
	 * 分类
	 */
	public function classs()
	{
		return $this->belongsTo(Classs::class);
	}

	/**
	 * 打开方式
	 */
	public function getTargetAttr($value){
		$config = config('tables.news.fields.target.options');
		return $config[$value];
	}

	/**
	 * 状态
	 */
	public function getStatusAttr($value){
		$config = config('tables.news.fields.status.options');
		return $config[$value];
	}

	/**
	 * 推荐
	 */
	public function getRecommendAttr($value){
		$config = config('tables.news.fields.recommend.options');
		return $config[$value];
	}

	/**
	 * 置顶
	 */
	public function getToppingAttr($value){
		$config = config('tables.news.fields.recommend.options');
		return $config[$value];
	}

	/**
	 * 排序时间
	 */
	public function setSortTimeAttr($value){
		return strtotime($value);
	}
	public function getSortTimeAttr($value){
		return date('Y-m-d H:i:s',$value);
	}
}
